<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>异常行为查询</title>
    <script src="../../static/js/jquery.min.js"></script>
    <link rel="stylesheet" href="../../static/css/reset.css">
    <link rel="stylesheet" href="../../static/css/common.css">
    <link rel="stylesheet" href="../../static/css/query.css">
    <link rel="stylesheet" type="text/css" href="../../static/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../static/themes/icon.css">
	<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
    <script src="../../static/js/Comm.js"></script>
    <script src="../../static/js/CommonTool.js"></script>
    <script src="../../static/js/Common.js"></script>
    <script type="text/javascript">
        $(function () {
            FitDatagridHeight('tbGrid');
            GetSearchData();
        });

        var _pageNumber;
        var _pageSize;

        function GetSearchData() {
            _pageNumber = 1;
            _pageSize = 24;
            LoadGridData(_pageNumber, _pageSize);
        }

        function LoadGridData(_pageNumber, _pageSize) {
            var Params = {
                PageNumber: _pageNumber,
                PageSize: _pageSize,
            }
            $.ajax({
                url: '../../queryAB',
                type: 'POST',
                data: Params,
                dataType: 'text',
                async: false,//同步

                error: function () {
                    $.messager.alert('提示', '加载错误!');
                },
                success: function (Resdata) {
                    $('#tg').datagrid({
                        columns: [[
                            { field: 'measuringPoint', title: '测量点', width: 200, align: 'center', sortable: true },
                            {
                                field: 'aDate', title: '日期', align: 'center', width: 100, sortable: true, formatter: function (value, rec) {
                                    return format(rec.aDate, "yyyy-MM-dd");
                                }
                            },
                            { field: 'aMoment', title: '时刻', width: 100, align: 'center',formatter:
                                function (value, rec){
                                    return rec.aMoment+":00";
                                }
                            },
                            { field: 'fom', title: '计量方式', width: 100, align: 'center'},
                            { field: 'aCondition', title: '异常情况', width: 100, align: 'center' },
                            {
                                field: 'Control', title: '操作', width: 200, align: 'center', formatter: function (value, rec) {

                                    var title = '<a href="../chart/chart.html" id="c1" class="c1" onclick="edit(\'' + rec.measuringPoint+','+ rec.aDate+ '\')">查看用电详情</a>';
                                    return title;
                                }
                            }
                        ]],
                        onLoadSuccess: function (data) {
                            $('.c1').linkbutton({ text: '查看用电详情', plain: true, iconCls: 'icon-edit' });
                        },
                        width: 'auto',
                        data: eval('(' + Resdata + ')'),
                        singleSelect: true,
                        pagination: true,
                        remoteSort: false,
                        idField: 'ID',
                        fit: true,
                        loadMsg: '数据加载中...',
                        iconCls: 'icon-ok',
                        title: "异常信息",
                        pageSize: _pageSize,
                        pageNumber: _pageNumber,
                        pageList: [12,24]
                    })
                }
            })
            var pg = $("#tg").datagrid("getPager");
            if (pg) {
                $(pg).pagination(
                    {
                        pageNumber: _pageNumber,
                        pageSize: _pageSize,
                        pageList: [12,24],
                        onSelectPage: function (pageNumber, pageSize) {
                            LoadGridData(pageNumber, pageSize);
                        },
                        onChangePageSize: function (pageSize) {
                            LoadGridData(pageNumber, pageSize);
                        },
                        displayMsg: "当前显示 {from} - {to} 条记录  共 {total} 记录",
                        beforePageText: "第",
                        afterPageText: "共 {pages} 页"
                    }
                );
            }
        }

        function edit(measuringPoint,aDate){

        }

        var format = function(time, format){
            var t = new Date(time);
            var tf = function(i){return (i < 10 ? '0' : '') + i};
            return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){
                switch(a){
                    case 'yyyy':
                        return tf(t.getFullYear());
                        break;
                    case 'MM':
                        return tf(t.getMonth() + 1);
                        break;
                    case 'mm':
                        return tf(t.getMinutes());
                        break;
                    case 'dd':
                        return tf(t.getDate());
                        break;
                    case 'HH':
                        return tf(t.getHours());
                        break;
                    case 'ss':
                        return tf(t.getSeconds());
                        break;
                }
            })
        }

    </script>
</head>
<body>
    <div class="box">
        <header class="header">
            <h1>异常用电行为查询系统</h1>
        </header>
        <section class="query-content">
            <h2>异常行为查询</h2>
            <div class="query" style="width: 810px; height: 400px; margin: 0 auto" id="tbGrid">
                <table id="tg" title="异常记录" style="width:100%"></table>
            </div>
        </section>
    </div>
</body>

</html>